package com.cx.java;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cx.cx.pojo.Car;

/**
 * Servlet implementation class Details
 */
@WebServlet("/Details")
public class DetailsServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DetailsServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		// 根据id查看车辆详情，id需要从页面传递过来 id
				String id = request.getParameter("id");
				JdbcUtils ju = JdbcUtils.getInstance();
				
				String sql = "Select * from car where id="+ id;
				
				List<Car> carname = ju.executeQuery(Car.class, sql);
				
				HttpSession session = request.getSession();
				session.setAttribute("carname",carname );
				
					response.sendRedirect("/car/details.jsp");
					}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
